package com.goldcn.user.controller;

/**
 * @Author Tim Peng
 * mail: lmn_022@163.com
 * Date: 2017/8/8
 * Time: 16:19
 * To change this template use File | Settings | File Templates.
 */

import com.goldcn.common.consts.RestConst;
import com.goldcn.common.exception.ServiceException;
import com.goldcn.user.model.GoldSeting;
import com.goldcn.user.service.GoldSetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@Api(value = "金价设置")
@RestController
@RequestMapping(value = "/goldSeting")
public class GoldSetingController {

    @Autowired
    GoldSetingService goldSetingService;

    @ApiOperation(value = "根据成色查询金价")
    @RequestMapping(value = "/info/{supplierID}/{necklace}",method = RequestMethod.GET)
    public Object getGoldSetingByNecklace(@PathVariable Long supplierID,@PathVariable String necklace){
        return goldSetingService.getGoldSetingByNecklace(supplierID,necklace);
    }

    @ApiOperation(value = "修改")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    public Object update(@RequestBody GoldSeting goldSeting){
        return goldSetingService.update(goldSeting);
    }

    @ApiOperation(value = "查询金价列表")
    @RequestMapping(value = "/selectAll/{supplierID}",method = RequestMethod.POST)
    public Object selectAll(@PathVariable Long supplierID){
        return goldSetingService.selectAllBySupplierID(supplierID);
    }

    @ApiOperation(value = "根据成色查询当日金价")
    @RequestMapping(value = "/searchGoldPriceByNecklace/{supplierID}/{necklace}",method = RequestMethod.GET)
    public Object getGoldPriceByNecklace(@PathVariable Long supplierID,@PathVariable String necklace){
        return goldSetingService.searchGoldPriceByNecklace(supplierID,necklace);
    }
}
